#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int x,y,a,b;
int gcd(int a,int b){
    return b==0? a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int main(void){
    scanf("%d%d%d%d",&x,&y,&a,&b);
    int t=lcm(x,y);
    int cnt=(b/t)-(a-1)/t;
    printf("%d\n",cnt);
    return 0;
}